package org.glorylight.hacks.social.model;

import java.io.Serializable;
import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Type;

@Entity
@Table(name = "message")
@NamedQueries({
	@NamedQuery(name = "message-by-user", query = "from Message a where a.recipient = :userId or a.sender = :userId")
	})
public class Message implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -7416234130983777958L;

	@Id
	@Type(type = "uuid")
	@Column(length = 32)
	private UUID id;

	@Column(name = "sender")
	private String sender;
	
	@Column(name = "recipient")
	private String recipient;
	
	@Column(name = "subject")
	private String subject;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "date_created")
	private Date dateCreated;
	
	@Column(name = "description")
	private String description;
	
	@Column(name = "isNew")
	private boolean isNew;

	public Message(UUID id, String sender, String recipient, String subject, 
				Date dateCreated, String description, boolean isNew){
		this.id = id;
		this.sender = sender;
		this.recipient = recipient;
		this.dateCreated = dateCreated;
		this.subject = subject;
		this.description = description;
		this.isNew = isNew;
	}
	
	public Message() {
	}
	
	public UUID getId() {
		return id;
	}

	public void setId(UUID id) {
		this.id = id;
	}

	public String getSender() {
		return sender;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getRecipient() {
		return recipient;
	}

	public void setRecipient(String recipient) {
		this.recipient = recipient;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean isNew() {
		return isNew;
	}

	public void setNew(boolean isNew) {
		this.isNew = isNew;
	}
}
